module.exports = {
	data() {
		return {}
	},
	onLoad() {
		
		this.$u.getRect = this.$uGetRect
	},
	methods: {
		
		
		
		$uGetRect(selector, all) {
			return new Promise(resolve => {
				uni.createSelectorQuery().
				in(this)[all ? 'selectAll' : 'select'](selector)
					.boundingClientRect(rect => {
						if (all && Array.isArray(rect) && rect.length) {
							resolve(rect)
						}
						if (!all && rect) {
							resolve(rect)
						}
					})
					.exec()
			})
		},
		getParentData(parentName = '') {
			
			if(!this.parent) this.parent = false;
			
			
			
			this.parent = this.$u.$parent.call(this, parentName);
			if(this.parent) {
				
				Object.keys(this.parentData).map(key => {
					this.parentData[key] = this.parent[key];
				});
			}
		},
		
		preventEvent(e) {
			e && e.stopPropagation && e.stopPropagation()
		}
	},
	onReachBottom() {
		uni.$emit('uOnReachBottom')
	},
	beforeDestroy() {
		
		
		if(this.parent && uni.$u.test.array(this.parent.children)) {
			
			const childrenList = this.parent.children
			childrenList.map((child, index) => {
				
				if(child === this) {
					childrenList.splice(index, 1)
				}
			})
		}
	}
}
